<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>自动切图</title>
    <script type="text/javascript">
        window.onload = function () {

            var img1 = document.getElementById("id");
            var imgArr = ["1.jpg", "2.jpg", "3.jpg", "4.jpg"];
            var index = 0;
            setInterval(function () {
                index++;
                if (index>=imgArr.length){
                    index=0;
                }
                img1.src = imgArr[index]
            }, 1000)
        }
    </script>
</head>
<body>
<img id="id" src="1.jpg" width="1040" height="540">
</body>
</html>